<template>
  <div>
    <van-row style="padding-top: 1rem;padding-bottom: 1rem">
      <van-col span="12">
        <table>
          <tr>
            <th>任务id</th>
            <th>我的任务</th>
          </tr>
          <tr v-for="(i,j) in tasklist" :key="j" @click="taskquery(i.id)">
            <td>{{j+1}}</td>
            <td>{{i.id}}</td>
          </tr>
        </table>
      </van-col>
      <van-col span="12">
        <table v-if="info!={}">
          <tr>
            <th>任务id</th>
            <th>任务名称</th>
            <th>审批人编号</th>
            <th>审批内容</th>
          </tr>
          <tr>
            <td>{{info.id}}</td>
            <td>{{info.title}}</td>
            <td><p v-for="i in info.approver" :key="">i</p></td>
            <td></td>
          </tr>
        </table>
        {{info}}
      </van-col>
    </van-row>
  </div>
</template>

<script>
import myaxios from "../../../https/myaxios";

export default {
  name: "mytask",
  data(){
    return{
      tasklist:[],
      info:'',
    }
  },
  methods:{
    taskquery(val){
      myaxios("taskquery?text="+val,"get").then(res=>{
        this.info=res.list
        this.info["params"]=JSON.parse(res.list["params"])
      })
    },
    gettask(){
      myaxios("mytask?userid="+localStorage.getItem("userid"),"get").then(res=>{
        this.tasklist=res.list
        for(let i=0;i<this.tasklist.length;i++){
          this.tasklist[i]["title"] = JSON.parse(this.tasklist[i]["title"])
        }

      })
    },
  },
  mounted() {
    this.gettask()
  }
}
</script>

<style scoped>

</style>